package com.twittex.view
{
	import com.twittex.TwittexFacade;
	import com.twittex.model.vo.UserVO;
	import com.twittex.view.components.UserScreen;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class UserScreenMediator extends Mediator
	{
		public static const NAME:String = "UserScreenMediator";

		
		public function UserScreenMediator(viewComponent:UserScreen) {
			super(NAME, viewComponent);
		}
		
		override public function onRegister():void {
			sendNotification(TwittexFacade.FIND_USER);	
		}

        override public function listNotificationInterests():Array {
            return [ 
					TwittexFacade.USER_FOUND
					];
        }

        override public function handleNotification( note:INotification ):void {
            switch ( note.getName() ) 
			{
				case TwittexFacade.USER_FOUND:
					userScreen.user = note.getBody() as UserVO;
					break;
            }
        }
        
        protected function get userScreen():UserScreen {
        	return viewComponent as UserScreen;
        }
	}
}